package com.whj.wkpt.mapper;

import com.whj.wkpt.entity.Payment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PaymentMapper {
    
    Payment findById(Long paymentId);
    
    @Insert("INSERT INTO payments(task_id, amount, payment_time, payment_status, create_time, update_time) " +
            "VALUES(#{taskId}, #{amount}, #{paymentTime}, #{paymentStatus}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "paymentId")
    int insert(Payment payment);
    
    @Update("UPDATE payments SET task_id=#{taskId}, amount=#{amount}, payment_time=#{paymentTime}, " +
            "payment_status=#{paymentStatus}, update_time=#{updateTime} " +
            "WHERE payment_id=#{paymentId}")
    int update(Payment payment);
    
    @Delete("DELETE FROM payments WHERE payment_id = #{paymentId}")
    int deleteById(Long paymentId);
    
    List<Payment> findAll();
    
    List<Payment> findByTaskId(Long taskId);
}